<!DOCTYPE html>
<html class="x-admin-sm">
    <head>
        <meta charset="UTF-8">
        <title>欢迎页面-X-admin2.2</title>
        <meta name="renderer" content="webkit">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8"/>
        <link rel="stylesheet" href="/static/admin/css/font.css">
        <link rel="stylesheet" href="/static/admin/css/xadmin.css">
        <script src="/static/admin/lib/layui/layui.js" charset="utf-8"></script>
        <script type="text/javascript" src="/static/admin/js/xadmin.js"></script>
        <script type="text/javascript" src="https://code.jquery.com/jquery-3.4.1.js"></script>
    </head>
<body>

    <div class="x-nav">
        <span class="layui-breadcrumb">
            <a href="">首页</a>
            <a href="">演示</a>
            <a><cite>导航元素</cite></a>
        </span>
        <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right"
           onclick="location.reload()" title="刷新">
            <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i>
        </a>
    </div>


    <div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body ">
                    <form class="layui-form layui-col-space5" method="GET" action="{:url('admin/HousingRes/index')}">
                        <div class="layui-input-inline layui-show-xs-block">
                            <input class="layui-input"  value="{$where.hr_serial_number|default=''}" placeholder="房源编号" name="hr_serial_number">
                        </div>
                        <div class="layui-input-inline layui-show-xs-block">
                            <select name="hr_status" lay-filter="hr_status">
                                <option value="">房源状态</option>
                                <option value="1" {if isset($where.hr_status) and $where.hr_status==1}selected{/if}>未跟进</option>
                                <option value="2" {if isset($where.hr_status) and $where.hr_status==2}selected{/if}>已联系</option>
                                <option value="3" {if isset($where.hr_status) and $where.hr_status==3}selected{/if}>已实勘</option>
                                <option value="4" {if isset($where.hr_status) and $where.hr_status==4}selected{/if}>风控处理</option>
                                <option value="5" {if isset($where.hr_status) and $where.hr_status==5}selected{/if}>可签约</option>
                                <option value="6" {if isset($where.hr_status) and $where.hr_status==6}selected{/if}>已签约</option>
                                <option value="7" {if isset($where.hr_status) and $where.hr_status==7}selected{/if}>已失效</option>
                                <option value="8" {if isset($where.hr_status) and $where.hr_status==8}selected{/if}>溢出状态</option>
                            </select>
                        </div>

                        <div class="layui-input-inline layui-show-xs-block">
                            <select name="hr_sales_id" lay-filter="hr_sales_id">
                                <option value="">请选择业务员</option>
                                {volist name="saleslist" id="salesinfo"}
                                <option value="{$salesinfo.id}">{$salesinfo.truename}</option>
                                {/volist}
                            </select>
                        </div>

                        <div class="layui-input-inline layui-show-xs-block">
                            <select name="hr_cm_id" lay-filter="cm_id" id="cm_id">
                                <option value="">请选择渠道员</option>
                            </select>
                        </div>

                        <div class="layui-input-inline layui-show-xs-block">
                            <input class="layui-input" value="{$where.hr_owner|default=''}" placeholder="业主" name="hr_owner">
                        </div>

                        <div class="layui-input-inline layui-show-xs-block">
                            <input class="layui-input" value="{$where.hr_city|default=''}" placeholder="房源地区/省市区" name="hr_city">
                        </div>

                        <div class="layui-input-inline layui-show-xs-block">
                            <input class="layui-input" value="{$where.bc_name|default=''}" placeholder="房源商圈" name="bc_name">
                        </div>

                        <div class="layui-input-inline layui-show-xs-block">
                            <input class="layui-input" value="{$where.rq_name|default=''}" placeholder="小区名称" name="rq_name">
                        </div>

                        <div class="layui-input-inline layui-show-xs-block">
                            <button class="layui-btn" lay-submit="" lay-filter="sreach"><i class="layui-icon">&#xe615;</i></button>
                            <!--<input class="layui-btn" type="button" lay-submit lay-filter="*" value="搜索">-->
                        </div>
                    </form>
                </div>
                <div class="layui-card-header">
<!--                    <button class="layui-btn layui-btn-danger" onclick="delAll()">-->
<!--                        <i class="layui-icon"></i>批量删除-->
<!--                    </button>-->
                    <button class="layui-btn" onclick="xadmin.open('添加房源','HousingCreate')">
                        <i class="layui-icon"></i>添加
                    </button>
                </div>
                <div class="layui-card-body ">
                    <table class="layui-table layui-form">
                        <thead>
                        <tr>
<!--                            <th><input type="checkbox" name="" lay-skin="primary"></th>-->
                            <th>房源ID</th>
                            <th style="width:150px;">房源编号</th>
                            <th>业务员</th>
                            <th>渠道员</th>
                            <th>业主姓名</th>
                            <th>业主手机号</th>
                            <th>房源状态</th>
                            <th>房源地区</th>
                            <th>所属商圈</th>
                            <th>小区名称</th>
                            <th>小区地址</th>
<!--                            <th>面积</th>-->
                            <th>电量/年</th>
                            <th>操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        {volist name="data" id="info"}
                        <tr>
<!--                            <td><input type="checkbox" name="aa" lay-skin="primary"></td>-->
                            <td>{$info.hr_id}</td>
                            <td>{$info.hr_serial_number|default='暂无'}</td>
                            <td style="width:80px">{$info.truename}</td>
                            <td style="width:80px">{$info.cm_name|default='暂无'}</td>
                            <td style="width:80px">{$info.hr_owner}</td>
                            <td>{$info.hr_owner_phone}</td>
                            <td>{$info.hr_status_text}</td>
                            <td>{$info.hr_city}</td>
                            <td>{$info.bc_name}</td>
                            <td>{$info.rq_name}</td>
                            <td>{$info.hr_entrance}单元{$info.hr_storey}层{$info.hr_house_number}号</td>
<!--                            <td>{$info.hr_house_area}</td>-->
                            <td class="hr_statistics" attr="{$info.hr_id}">
                                <input type="number"  style="width:85px;height:25px;" value="{$info.hr_statistics}">
                                <span class="layui-btn layui-btn-normal layui-btn-mini hr_statistics_button" style="position:relative;top:-30px;left:45px;">确定</span>
                            </td>
                            <td class="td-manage">
                                <a title="房源信息查看" onclick="xadmin.open('房源详情/编辑','housingRead.html?id={$info.hr_id}')" href="javascript:;">
                                    <i class="layui-icon">&#xe63c;</i></a>
                                <a title="添加房间" onclick="xadmin.open('添加房间','roomAdd.html?house_id={$info.hr_id}')" href="javascript:;">
                                    <i class="icon iconfont">&#xe6b9;</i>
                                </a>
                                <a title="房源出租信息" onclick="xadmin.open('房源出租信息','housingRental.html?house_id={$info.hr_id}')" href="javascript:;">
                                    <i class="icon iconfont">&#xe6fc;</i>
                                </a>
                            </td>
                        </tr>
                        {/volist}
                        </tbody>
                    </table>
                </div>
                <div class="layui-card-body ">
                    <div class="page">
                        <div>
                            {$data->render()|raw}
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
    <script>
        layui.use(['form', 'jquery', 'layer','table'], function () {
            var form = layui.form;
            var $ = layui.jquery;
            var layer = layui.layer;

            form.on('select(hr_sales_id)', function(data){
                sales_id = data.value;      //业务员id
                $.ajax({
                    type:'post',
                    dataType:'json',
                    data:{"hr_sales_id":sales_id},
                    url:'/admin/HousingRes/salesTochannel',
                    success:function(data){
                        $("#cm_id option:gt(0),#tco_id option:gt(0)").remove();
                        $.each(data.data.channellist, function(k, v) {
                            $('#cm_id').append(new Option(v.cm_name, v.cm_id));
                        });

/*                        $.each(data.data.ownerslist, function(k, v) {
                            $('#tco_id').append(new Option(v.tco_owners_name, v.tco_id));
                        });*/
                        form.render('select');
                    },
                    error:function(){
                        layer.msg('请求有误',{time: 2000, icon:6,end:function () {
                                location.reload();
                        }})
                    },
                });
            });

            $(".hr_statistics_button").click(function(){
                hr_statistics = $(this).siblings("input").val();
                hr_id = $(this).parent("td").attr("attr");
                $.ajax({
                    type:'post',
                    dataType:'json',
                    data:{"hr_statistics":hr_statistics,"hr_id":hr_id},
                    url:'/admin/HousingRes/statisticsEdit',
                    success:function(data){
                        if (data.code==0) {
                            layer.msg(data.msg,{time: 2000, icon:6,});
                        } else {
                            layer.msg(data.msg,{time: 2000, icon:5,end:function () {
                                    location.reload();
                            }});
                        }
                    },
                    error:function(){
                        layer.msg('请求有误',{time: 2000, icon:5,end:function () {
                                location.reload();
                        }})
                    },
                });
            });
        });
    </script>
</html>